<%-- 
    Document   : edit
    Created on : 8 mars 2011, 18:27:24
    Author     : B-fly
--%>
<%@page import="javax.swing.text.AbstractDocument.Content"%>
<%@page import="java.awt.TextArea"%>
<%@page import="Model.ListWord"%>
<%@page import="Model.ListWord"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>eWiki</title>
        <link rel="stylesheet" media="screen" type="text/css" title="Design" href="../design.css"/>
        <script language="Javascript">
            var isMozilla = (navigator.userAgent.toLowerCase().indexOf('gecko')!=-1) ? true : false;
            var regexp = new RegExp("[\r]","gi");

            function storeCaret(selec,d)
            {
                    if (isMozilla)
                    {
                    // Si on est sur Mozilla
                            oField = document.forms['news'].elements['newst'];
                            objectValue = oField.value;
                            deb = oField.selectionStart;
                            fin = oField.selectionEnd;
                            objectValueDeb = objectValue.substring( 0 , oField.selectionStart );
                            objectValueFin = objectValue.substring( oField.selectionEnd , oField.textLength );
                            objectSelected = objectValue.substring( oField.selectionStart ,oField.selectionEnd );
                    //	alert("Debut:'"+objectValueDeb+"' ("+deb+")\nFin:'"+objectValueFin+"' ("+fin+")\n\nSelectionné:'"+objectSelected+"'("+(fin-deb)+")");
                            if(d==2){
                                oField.value = objectValueDeb + selec  + objectSelected + selec + objectValueFin;
                                oField.selectionStart = strlen(objectValueDeb);
                                oField.selectionEnd = strlen(objectValueDeb + selec + objectSelected + selec);
                            } else if (d==1){
                                oField.value = objectValueDeb + selec  + objectSelected + objectValueFin;
                                oField.selectionStart = strlen(objectValueDeb);
                                oField.selectionEnd = strlen(objectValueDeb + selec + objectSelected );
                            } else if (d==3){
                                oField.value = objectValueDeb + selec  + objectSelected + "]" + objectValueFin;
                                oField.selectionStart = strlen(objectValueDeb);
                                oField.selectionEnd = strlen(objectValueDeb + selec + objectSelected + "]");
                            }
                            oField.focus();
                            oField.setSelectionRange(
                                objectValueDeb.length + selec.length + 2,
                                objectValueDeb.length + selec.length + 2);
                    }
                    else
                    {
                    // Si on est sur IE
                            oField = document.forms['news'].elements['newst'];
                            var str = document.selection.createRange().text;

                            if (str.length>0)
                            {
                            // Si on a selectionné du texte
                                    var sel = document.selection.createRange();
                                    if (d==1)
                                        sel.text = selec + str ;
                                    else if (d==2)
                                        sel.text = selec + str + selec ;
                                    else if (d==3)
                                        sel.text = selec + str + "]" ;
                                    sel.collapse();
                                    sel.select();
                            }
                            else
                            {
                                    oField.focus(oField.caretPos);
                                    oField.focus(oField.value.length);
                                    oField.caretPos = document.selection.createRange().duplicate();
                                    var bidon = "%~%";
                                    var orig = oField.value;
                                    oField.caretPos.text = bidon;
                                    var i = oField.value.search(bidon);
                                    if (d==1)
                                        oField.value = orig.substr(0,i) + selec + orig.substr(i, oField.value.length);
                                    else if (d==2)
                                        oField.value = orig.substr(0,i) + selec + selec + orig.substr(i, oField.value.length);
                                    else if (d==3)
                                        oField.value = orig.substr(0,i) + selec + "]" + orig.substr(i, oField.value.length);
                                    var r = 0;
                                    for(n = 0; n < i; n++)
                                    {if(regexp.test(oField.value.substr(n,2)) == true){r++;}};
                                    pos = i + 2 + selec.length - r;
                                    var r = oField.createTextRange();
                                    r.moveStart('character', pos);
                                    r.collapse();
                                    r.select();
                            }
                    }
            }/* http://www.editeurjavascript.com/countus/ */
    </script>
    </head>
    <body>
<<<<<<< .mine
        <div class="entete">
                <div id="location">
                    Edit
                </div>
                <div id="logo">
                    eWiki
                </div>
            <div id="info">
                <%=new SimpleDateFormat("dd/MM/yyyy").format(new Date()) %>
                 at : <%=new SimpleDateFormat("HH:mm:ss").format(new Date()) %>
            </div>
        </div>
        <div id="menu">
            <table>
            <tr>
                <td>
                    <form action="Home" method="POST">
                        <input type="submit" value="Home" class="bouton"/>
                    </form>
                </td>
                <td>
                    <form action="View" method="POST">
                        <input type="submit" value="View" class="bouton"/>
                    </form>
                </td>
                <!--
                <td>
                    <form action="Edit" method="POST">
                        <input type="submit" value="Edit" class="bouton"/>
                    </form>
                </td>
                -->
                <td>
                    <form action="History" method="POST">
                        <input type="submit" value="History" class="bouton"/>
                    </form>
                </td>
            </tr>
            </table>
=======
        <center>
            <form name="news">
                <input type="button" value="B" style="width:50px;font-weight:bold" onclick="storeCaret('++',2)">
                <input type="button" value="I" style="width:50px;font-style:italic" onclick="storeCaret('+',2)">
                <input type="button" value="[lien]" style="width:50px;text-decoration:underline" onclick="storeCaret('[',3)">
                <input type="button" value="[http://]"style="width:50px" onclick="storeCaret('[http://',3)">
                <input type="button" value="<h1>"style="width:50px" onclick="storeCaret('!',1)">
                <input type="button" value="<h2>"style="width:50px" onclick="storeCaret('!!',1)">
                <input type="button" value="<h3>"style="width:50px" onclick="storeCaret('!!!',1)">
                <input type="button" value="ligne"style="width:50px" onclick="storeCaret('---',1)"><br>

                <% if (session.getAttribute("page")!=null) %>
                <textarea name="newst" id="content" rows="25" wrap="virtual" cols="45"><% {out.println(session.getAttribute("edition").toString().substring(1));%></textarea>
                <% } %>
            </form>

       </center>
       <div id="validation">
            <form action="Edition" method="POST">
                <input type="submit" value="Submit" class="bouton"/>
                <% session.setAttribute("edition", ); %>
            </form>
>>>>>>> .r33
       </div>
        <div id="sidebar">
            SideBar
        </div>
        <div id="page">
            <div id="entete">
                <h1><html:outputText value="#{listWord.word}" /></h1>
            </div>
            <div>
                <html:inputText value="#{listWord.text}" />
            </div>
        </div>
    </body>
</html>
